package com.fmi.timedealer.moodgame;

import android.graphics.Bitmap;
import android.graphics.Point;

public class CircleUtils {

	public static Point getCenter(int x, int y, int width, int height) {
		
		int xDimension = x + width / 2;
		int yDimension = y + height / 2;
		return new Point(xDimension, yDimension);
	}
	
	public static Point getCenter(int x, int y, Bitmap bitmapObject) {
		return getCenter(x, y, bitmapObject.getWidth(), bitmapObject.getHeight());
	}
	
	public static int getRadius(int width, int height) {
		
		if (width < height) {
			return width / 2;
		}
		else {
			return height / 2;
		}
	}
	
	public static int getRadius(Bitmap bitmapObject) {
		return getRadius(bitmapObject.getWidth(), bitmapObject.getHeight());
	}
	
	public static boolean hasCollision(Point sCenter, Point dCenter, int sRadius, int dRadius) {
		
		int xCathetus = Math.abs(sCenter.x - dCenter.x);
		int yCathetus = Math.abs(sCenter.y - dCenter.y);
		return Math.sqrt(xCathetus * xCathetus + yCathetus * yCathetus) < (sRadius + dRadius);
	}
	
	public static boolean hasCollision(BallView sView, MoodView dView) {
		return hasCollision(sView.getCenter(), dView.getCenter(), sView.getRadius(), dView.getRadius());
	}
}
